package com.eos.control.action.ajax;

import java.util.List;

import com.eos.common.tool.DataCacheUtil;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysMenu;

public class GetFunctionAjax extends AbstractBaseAction{
	private static final long serialVersionUID = -1843566956842756938L;
	private String result;
	private Integer menuId;
	
	public String getResult() {
		return result;
	}

	public void setMenuId(Integer menuId) {
		this.menuId = menuId;
	}


	@Override
	public String execute() {
		try {
			List<SysMenu> menuList = DataCacheUtil.getAllSysMenu();
			if(null != menuId){
				for(SysMenu menu : menuList){
					if(menu.getId().intValue() == menuId){
						result = ObjectUtils.beanToJson(menu);
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
